package com.whcoding.designpatterns.pattern.adapter;

/**
 * @program: spring-boot-learning
 * @description:对象适配器
 * @author: whcoding
 * @create: 2022-09-20 17:06
 **/
public class ObjectVoltageAdaptor implements IVoltage5V {

	private Voltage220V voltage220V;

	/**
	 * 通过构造器传入一个Voltage220V的对象实例
	 *
	 * @param voltage220V
	 */
	public ObjectVoltageAdaptor(Voltage220V voltage220V) {
		this.voltage220V = voltage220V;
	}

	@Override
	public int output5V() {
		int outputV = 0;
		if (null != voltage220V) {
			int inputV = voltage220V.output220V();
			outputV = inputV / 44;
		}
		return outputV;
	}
}
